<?php
declare(strict_types=1);
namespace Service\GoodsService;
use Service\BaseService;
use App\Model\BbcModel\DistributorPrice;

/**
 * 分销商商品规格价格服务中心
 * @author chenshubo
 */
class DistributorSpecPriceService extends BaseService
{
    /**
     * 获取商品规格价格
     * @param array $goodsIds
     */
    public function getGoodsDistributorPriceList( array $goodsIds)
    {
        return DistributorPrice::instance()
        ->whereIn('goods_id',$goodsIds)
        ->get()
        ->toArray();
    }
    
    /**
     * 获取分组功能
     * 商品
     *    |_等级
     *         |_规格
     * @param array $data
     */
    public function getMapList( array $data )
    {
        if( empty($data) ) {
            return [];
        }
        
        $temp = [];
        foreach ($data as $item)
        {
            $temp[$item['goods_id']][$item['level_id']][$item['spec_num']] = $item;
            unset($item);
        }
        
        return $temp;
    }
}